﻿using ChestPainCenterSystem.Code.Bll;
using ChestPainCenterSystem.Core;
using ChestPainCenterSystem.ThreeCenterManage;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace ChestPainCenterSystem.Areas.ChestPainCenter.Controllers
{
    public class PathwayExeController : BaseController
    {
        //
        // GET: /ChestPainCenter/PathWayExe/

        public ActionResult Index()
        {
            return View();
        }

        protected ChestPainCenterSystem.ThreeCenterManage.TimeLine[] MODEL;
        protected ChestPainCenterSystem.ThreeCenterManage.PatientInfo Patient;
        /// <summary>
        /// 质控点列表
        /// </summary>
        /// <returns></returns>
        public ActionResult Search(string PatientID)
        {
            OperateResult resultInfo = PathwayManager.GetOpenQuanlityPointList(PatientID);
            if (resultInfo.Body.GetType().Name == "DataCompleteTimeLine")
            {
                DataCompleteTimeLine rst = resultInfo.Body as DataCompleteTimeLine;
                MODEL = rst.TimeLine;
                foreach (TimeLine temp in MODEL)
                {
                    DateTime outCompareTime;
                    if (!temp.OverTimeBool && (temp.Time == null || temp.Time == "") && temp.ComparePointTime != null && DateTime.TryParse(temp.ComparePointTime, out outCompareTime))
                    {
                        TimeSpan ts = outCompareTime - DateTime.Now;
                        if (ts.TotalMinutes <= 5)
                        {
                            temp.Tag = "<font style='color:red';>即将超时</font>";
                        }
                    }
                }
                Patient = rst.PatientInfo;
                ViewData["Patient"] = Patient;
            }
            var res = new { Rows = MODEL };
            return JsonDate(res);
        }

        public ActionResult Detail()
        {
            return View();
        }
    }
}
